package com.xm.oj.model.enums;

import org.apache.commons.lang3.ObjectUtils;


/**
 * 题目提交状态枚举
 */
public enum QuestionSubmitStatusEnum {
    WAITING("待判题", 0),

    RUNNING("判题中", 1),

    SUCCESS("成功", 2),

    FAILURE("失败", 3);

    /**
     * 状态
     */
    private final String text;


    /**
     * 状态码
     */
    private final Integer value;



    QuestionSubmitStatusEnum(String text, Integer value) {
        this.text = text;
        this.value = value;
    }

    public QuestionSubmitStatusEnum getEnumByCode(Integer value){
        if (ObjectUtils.isEmpty(value)){
            return null;
        }
        for (QuestionSubmitStatusEnum oneEnum : QuestionSubmitStatusEnum.values()){
            if (oneEnum.value.equals(value)){
                return oneEnum;
            }
        }
        return null;
    }
    public Integer getValue() {
        return value;
    }

    public String getText() {
        return text;
    }
}
